<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h3 class="title">Paracelsus - Integração Digital do SUS</h3>
            <hr/>
            <h:form id="agenteForm" enctype="multipart/form-data">
                <br/>
                <h3 class="title"></h3>
                <p:growl id="messages" showDetail="true" autoUpdate="true"  /> 
                <p:panel id="personPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix both ">

                    <p:pieChart  value="#{managerPieModel.pieModel}" legendPosition="w"  
                                 showDataLabels="true"  legendCols="3"  dataFormat="value"
                                 title="Quantidade de Pacientes com :" style="height:350px;" >
                        <p:ajax event="itemSelect" oncomplete="dlg.show();" listener="#{managerPieModel.itemSelect}" update="@form" />
                    </p:pieChart>
                    
                    <p:pieChart  value="#{managerPieModel.pieModelMicro}" legendPosition="w"  
                                 showDataLabels="true"  legendCols="3"  dataFormat="value"
                                 title="Quantidade de Famílias por Micro Área :" style="height:350px;" />

                </p:panel>
                <div class="clear"/>
                <br/>
                <p:dialog id="dlg" widgetVar="dlg" header="Lista de Paciente" dynamic="true"
                          modal="true" appendToBody="false" resizable="false" width="70%" height="400px" draggable="false" closable="false">

                    <h3 class="title">Lista de Pacientes com #{managerPieModel.nomeDoenca} </h3>
                    <hr/>
                    <div class="buttonAction">

                        <p:panel id="resultPanel" style="background: none; border: none;" 
                                 styleClass="container_24 clearfix ">
                            <h4 class="title">Resultado</h4>

                            <p:dataTable id="agenteTable" var="item" value="#{managerPieModel.dataModel}"
                                 styleClass="grid_24" rowIndexVar="rowid" 
                                 style="white-space: pre-wrap;" 
                                 binding="#{managerPieModel.searchResults}"
                                 rows="5" paginator="true" lazy="true"
                                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                                 currentPageReportTemplate="{currentPage} de {totalPages}"
                                 paginatorPosition="bottom" emptyMessage="Nenhum registro">

                                <f:facet name="header">
                                    <p:outputLabel value="Pacientes" />
                                </f:facet> 
                                <p:column headerText="Ação" width="100">                                 
                                    <p:button title="Visualizar"
                                              href="visualizarcidadao.xhtml?visualizarCidadao=#{item.id}"
                                              icon="ui-icon-zoomin"/> 
                                  
                                </p:column>

                                <p:column headerText="Nome" width="400">  
                                    <h:outputText value="#{item.cidadao.nome}" />

                                </p:column>
                                <p:column headerText="Numero SUS">  
                                    <h:outputText value="#{item.cidadao.numeroCartaoSus}"/>
                                </p:column> 
                                <p:column headerText="Unidade Básica ">  
                                    <h:outputText value="#{item.profissional.microArea.unidade.nome}"/>
                                </p:column> 

                            </p:dataTable> 

                        </p:panel>


                        <p:commandButton process=":agenteForm:agenteTable" oncomplete="dlg.hide()" value="Sair" />
                    </div>


                </p:dialog>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
